#define _GNU_SOURCE
#include "app_pool.h"
#include "unistd.h"

void app_pool_data_handler(void *args)
{
    sleep(1);
    printf("线程 %d 执行... 参数为:%s \n", gettid(), (char *)args);
    free(args);
}

int main(int argc, char const *argv[])
{
    // 创建一个线程池
    app_pool_init(5);

    // 模拟发送任务执行
    for (int i = 0; i < 10; i++)
    {
        char *data = (char *)malloc(11);
        sprintf(data, "atguigu_%d", i);
        app_pool_add_task(app_pool_data_handler, data);
    }

    sleep(5);

    // 关闭线程池
    app_pool_close();

    return 0;
}
